package com.p2p.auth.service;

import com.octo.captcha.engine.CaptchaEngine;
import com.octo.captcha.engine.image.ListImageCaptchaEngine;
import com.octo.captcha.service.captchastore.CaptchaStore;
import com.octo.captcha.service.captchastore.FastHashMapCaptchaStore;
import com.octo.captcha.service.image.AbstractManageableImageCaptchaService;

/**
 * Created by Antinomy on 16/10/14.
 */
public class ImageCaptchaService extends
        AbstractManageableImageCaptchaService implements com.octo.captcha.service.image.ImageCaptchaService {

    private static ImageCaptchaService instance;

    public static ImageCaptchaService getInstance() {
        if (instance == null) {
            //use customized engine
            ListImageCaptchaEngine engine = new ImageCaptchaEngine();
            instance = new ImageCaptchaService(
                    new FastHashMapCaptchaStore(), engine, 180, 99000000, 75000);
        }
        return instance;
    }

    public ImageCaptchaService(CaptchaStore captchaStore,
                               CaptchaEngine captchaEngine,
                               int minGuarantedStorageDelayInSeconds,
                               int maxCaptchaStoreSize,
                               int captchaStoreLoadBeforeGarbageCollection) {
        super(captchaStore, captchaEngine, minGuarantedStorageDelayInSeconds,
                maxCaptchaStoreSize, captchaStoreLoadBeforeGarbageCollection);
    }
}